-- @Author: 作者QQ201878826
-- @Date:   2022-05-02 22:01:54
-- @Last Modified by:   作者QQ381990860
-- @Last Modified time: 2022-07-23 06:58:54
--======================================================================--
-- @作者: QQ381990860
-- @创建时间:   2019-12-03 02:17:19
-- @Last Modified time: 2019-12-17 04:46:04
--======================================================================--
local 场景类_抽奖 = class()
local tp,zts,zts1
local floor = math.floor
local tonumber = tonumber
local tostring = tostring
local bwh = require("gge包围盒")
local bw = bwh(0,0,105,80)
--local 矩阵 = require("gge包围盒")(180,235,100,130)
local insert = table.insert
	local sl = 0
	local js= 1
	local sjs =0
function 场景类_抽奖:初始化(根)
	self.ID = 127
	self.x = 220+(全局游戏宽度-800)/2
	self.y = 160
	self.xx = 0
	self.yy = 0
	self.注释 = "镇 魔 卫 道"
	self.可视 = false
	self.鼠标 = false
	self.焦点 = false
	self.可移动 = true
	local 按钮 = 根._按钮
	local 自适应 = 根._自适应
	local 资源 = 根.资源
	self.资源组 = {
	    [0] = 自适应.创建(0,1,365,283,3,9),
	  --  [1] = 资源:载入('JM.dll',"网易WDF动画",0x65C595A9),
	   -- [2] = 资源:载入('JM.dll',"网易WDF动画",0x28A3B224),
		[3] = 按钮.创建(自适应.创建(18,4,16,16,4,3),0,0,4,true,true),
       	[4] = 按钮.创建(自适应.创建(11,4,70,20,1,3),0,0,4,true,true,"确定挑战"),
		[5] = 按钮.创建(自适应.创建(21,4,18,18,4,3),0,0,4,true,true),
		[6] =  自适应.创建(3,1,60,18,1,3),
		[7] =  自适应.创建(3,1,60,18,1,3),
		[8] =  自适应.创建(3,1,60,18,1,3),
		[9] =  自适应.创建(3,1,115,18,1,3),
		[10] = 自适应.创建(3,1,115,18,1,3),
		[11] = 根._小型选项栏.创建(自适应.创建(0,1,85,125,3,9),"本次挑战阶数："),
		[12] = 自适应.创建(3,1,130,18,1,3),
	}
	

	for i=3,5 do
		self.资源组[i]:绑定窗口_(127)
	end
	self.选择购买="   1阶"
    -- self.资源组[12]:绑定窗口_(127)
 -- self.介绍文本 = 根._丰富文本(self.x+12,self.y+29,根.字体表.普通字体)
 -- self.介绍文本:添加文本("#W/点击#Y/“备战”#W/进入备战状态，点击#Y/“取消”#W/结束备战，#Y/备战时间最慢为2分钟#W/轮空将直接进入下一轮！(#R胜利奖励积分，失败则无积分奖励#Y/)")
	self.窗口时间 = 0
	tp = 根
	zts = tp.字体表.普通字体
	zts1 = tp.字体表.描边字体
end

function 场景类_抽奖:打开(数据)
	if self.可视 then
		self.可视 = false
		self.选择购买="   1阶"
		--local 匹配 =0
		   self.进程 = 1
		 --	客户端:发送数据(匹配,248,13)

	else
	if  self.x > 全局游戏宽度 then
      self.x = 220+(全局游戏宽度-800)/2
    end
		self.进程 = 1
		self.倒计时 = 1
		self.起始 = 0
		insert(tp.窗口_,self)
	    tp.运行时间 = tp.运行时间 + 1
	  	self.窗口时间 = tp.运行时间
	    self.可视 = true
		self.数据 = 数据
		
		
	end
end


function 场景类_抽奖:formatTime(time)
    local hour = math.floor(time/3600);
    local minute = math.fmod(math.floor(time/60), 60)
    local second = math.fmod(time, 60)
    local rtTime = string.format("%s小时%s分%s秒", hour, minute, second)
    return rtTime
end


function 场景类_抽奖:取阶数(数额)
    local 阶数 = 0
	
	
     if 数额 == "   1阶"  then 阶数 = 1
 elseif 数额 == "   2阶"  then 阶数 = 2
 elseif 数额 == "   3阶"  then 阶数 = 3
 elseif 数额 == "   4阶"  then 阶数 = 4
 elseif 数额 == "   5阶"  then 阶数 = 5
 elseif 数额 == "   6阶"  then 阶数 = 6
 elseif 数额 == "   7阶"  then 阶数 = 7
 elseif 数额 == "   8阶"  then 阶数 = 8
 elseif 数额 == "   9阶"  then 阶数 = 9
elseif 数额 == "   10阶"  then 阶数 = 10
elseif 数额 == "   11阶"  then 阶数 = 11
elseif 数额 == "   12阶"  then 阶数 = 12
elseif 数额 == "   13阶"  then 阶数 = 13
elseif 数额 == "   14阶"  then 阶数 = 14
elseif 数额 == "   15阶"  then 阶数 = 15
elseif 数额 == "   16阶"  then 阶数 = 16
elseif 数额 == "   17阶"  then 阶数 = 17
elseif 数额 == "   18阶"  then 阶数 = 18
elseif 数额 == "   19阶"  then 阶数 = 19
elseif 数额 == "   20阶"  then 阶数 = 20
elseif 数额 == "   21阶"  then 阶数 = 21
elseif 数额 == "   22阶"  then 阶数 = 22
elseif 数额 == "   23阶"  then 阶数 = 23
elseif 数额 == "   24阶"  then 阶数 = 24
elseif 数额 == "   25阶"  then 阶数 = 25
elseif 数额 == "   26阶"  then 阶数 = 26
elseif 数额 == "   27阶"  then 阶数 = 27
elseif 数额 == "   28阶"  then 阶数 = 28
elseif 数额 == "   29阶"  then 阶数 = 29
elseif 数额 == "   30阶"  then 阶数 = 30
elseif 数额 == "   31阶"  then 阶数 = 31
elseif 数额 == "   32阶"  then 阶数 = 32
elseif 数额 == "   33阶"  then 阶数 = 33
elseif 数额 == "   34阶"  then 阶数 = 34
elseif 数额 == "   35阶"  then 阶数 = 35
elseif 数额 == "   36阶"  then 阶数 = 36
elseif 数额 == "   37阶"  then 阶数 = 37
elseif 数额 == "   38阶"  then 阶数 = 38
elseif 数额 == "   39阶"  then 阶数 = 39
elseif 数额 == "   40阶"  then 阶数 = 40
elseif 数额 == "   41阶"  then 阶数 = 41
elseif 数额 == "   42阶"  then 阶数 = 42
elseif 数额 == "   43阶"  then 阶数 = 43
elseif 数额 == "   44阶"  then 阶数 = 44
elseif 数额 == "   45阶"  then 阶数 = 45
elseif 数额 == "   46阶"  then 阶数 = 46
elseif 数额 == "   47阶"  then 阶数 = 47
elseif 数额 == "   48阶"  then 阶数 = 48
elseif 数额 == "   49阶"  then 阶数 = 49
elseif 数额 == "   50阶"  then 阶数 = 50
elseif 数额 == "   51阶"  then 阶数 = 51
elseif 数额 == "   52阶"  then 阶数 = 52
elseif 数额 == "   53阶"  then 阶数 = 53
elseif 数额 == "   54阶"  then 阶数 = 54
elseif 数额 == "   55阶"  then 阶数 = 55
elseif 数额 == "   56阶"  then 阶数 = 56
end


    return 阶数
end

function 场景类_抽奖:显示(dt,x,y)
	self.焦点 = false
   	self.资源组[0]:显示(self.x+0,self.y+0)
	self.资源组[3]:显示(self.x+345,self.y+4)
	self.资源组[4]:显示(self.x+143,self.y+250)
	
	
	self.资源组[3]:更新(x,y)
	self.资源组[4]:更新(x,y)
	self.资源组[5]:更新(x,y)
	--self.资源组[12]:更新(x,y)
	--self.介绍文本:显示(self.x+12,self.y+105)
	
	tp.字体表.普通字体:置颜色(0xFFFFFFFF):显示(self.x+150,self.y+5,self.注释)
	
	 self.资源组[6]:显示(self.x+115,self.y+40)
	 self.资源组[7]:显示(self.x+115,self.y+70)
	 self.资源组[8]:显示(self.x+115,self.y+100)
	 self.资源组[9]:显示(self.x+235,self.y+40)
	self.资源组[10]:显示(self.x+235,self.y+70)
	
	
	self.资源组[11]:显示(self.x+217,self.y+230,x,y,self.鼠标)
	self.资源组[12]:显示(self.x+185,self.y+210)
	
	 tp.字体表.普通字体:置颜色(0xFFFFFFFF):显示(self.x+10,self.y+43,"本日最高阶数：")
	 tp.字体表.普通字体:置颜色(0xFFFFFFFF):显示(self.x+10,self.y+73,"历史最高阶数：")
	 tp.字体表.普通字体:置颜色(0xFFFFFFFF):显示(self.x+10,self.y+103,"镇魔声望：")
	 tp.字体表.普通字体:置颜色(0xFFFFFFFF):显示(self.x+190,self.y+43,"耗时：")
	 tp.字体表.普通字体:置颜色(0xFFFFFFFF):显示(self.x+190,self.y+73,"耗时：")
	 
	 tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x+135,self.y+43,self.数据.本日镇魔.当前)
	 tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x+135,self.y+73,self.数据.累计镇魔.当前)
	 tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x+135,self.y+103,self.数据.镇魔声望)
	 tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x+246,self.y+43,self:formatTime(self.数据.本日镇魔.耗时))
	 tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x+246,self.y+73,self:formatTime(self.数据.累计镇魔.耗时))
	 --tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x+190,self.y+43,"耗时：")
	-- tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x+190,self.y+43,"耗时：")
	 
	 
	 
	 
	 
	 
	 
	 
	 tp.字体表.普通字体:置颜色(0xFF20B2AA):显示(self.x+10,self.y+130,"1、挑战阶数越高，战斗难度越高，声望积分越高\n\n2、第二日连续挑战可以额外获得10点积分\n\n3、最多额外获得10积分")
	 tp.字体表.普通字体:置颜色(0xFFFFFFFF):显示(self.x+85,self.y+212,"本次挑战阶数：")
	-- tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x+201,self.y+213," 镇魔")
     tp.字体表.普通字体:置颜色(0xFF000000):显示(self.x + 227, self.y + 214,self.选择购买)
	 self.资源组[5]:显示(self.x+297,self.y+212)
	 
     -- if self.进程 == 2 then
	 -- self.倒计时 = 120- (os.time()-self.起始)
	 -- tp.字体表.普通字体:置颜色(0xFFFFFFFF):显示(self.x+165,self.y+114,"(备战中 "..self.倒计时.." 秒)")
	  -- if self.倒计时 == 0 then 
	    -- local 匹配 =0
		-- 客户端:发送数据(匹配,248,13,"11")
	    -- self.进程 = 1
		
	  -- end
	 
     -- end	 
   
	if self.鼠标 then
		if self.资源组[3]:事件判断() then
		 
			self:打开()
    	elseif self.资源组[4]:事件判断() then
		     -- if self.进程 ~= 2 then
			 -- self.起始 = os.time()
			 -- end
			 local 匹配 = self:取阶数(self.选择购买)
			 
			  
			 客户端:发送数据(匹配,252,13) ---内容.参数，内容.序号，序号，内容.文本
			 self:打开()

		 elseif self.资源组[5]:事件判断() then
		     local tb={"   1阶" ,"   2阶" ,"   3阶" ,"   4阶" ,"   5阶" ,"   6阶" ,"   7阶" ,"   8阶" ,"   9阶" ,"   10阶" ,"   11阶" ,"   12阶" ,"   13阶" ,"   14阶" ,"   15阶" ,"   16阶" ,"   17阶" ,"   18阶" ,"   19阶" ,"   20阶" ,"   21阶" ,"   22阶" ,"   23阶" ,"   24阶" ,"   25阶" ,"   26阶" ,"   27阶" ,"   28阶" ,"   29阶" ,"   30阶" ,"   31阶" ,"   32阶" ,"   33阶" ,"   34阶" ,"   35阶" ,"   36阶" ,"   37阶" ,"   38阶" ,"   39阶" ,"   40阶" ,"   41阶" ,"   42阶" ,"   43阶" ,"   44阶" ,"   45阶" ,"   46阶" ,"   47阶" ,"   48阶" ,"   49阶" ,"   50阶" ,"   51阶" ,"   52阶" ,"   53阶" ,"   54阶" ,"   55阶" ,"   56阶"}
		     self.资源组[11]:打开(tb)
		     self.资源组[11]:置选中(self.选择购买)
			

		 elseif self.资源组[11]:事件判断() then	 
			    self.资源组[11]:置选中(self.资源组[11].弹出事件)
            	self.选择购买=self.资源组[11].弹出事件
            	--self.称谓动画=tp.资源:载入(LabelData[self.选择购买].资源,"网易WDF动画",LabelData[self.选择购买].动画)
            	--self.称谓动画偏移=LabelData[self.选择购买].偏移
            	--self.选择价格=LabelData[self.选择购买].无文字
            self.资源组[11].弹出事件 = nil

		end
	end
	bw:置坐标(self.x+217,self.y+280)
end





function 场景类_抽奖:检查点(x,y)
	if self.资源组[0]:是否选中(x,y) or bw:检查点(x,y) then
		return true
	end
end

function 场景类_抽奖:初始移动(x,y)
	tp.运行时间 = tp.运行时间 + 1
	if not tp.消息栏焦点 then
  		self.窗口时间 = tp.运行时间
 	end
	if not self.焦点 then
		tp.移动窗口 = true
	end
	if self.鼠标 and  not self.焦点 then
		self.xx = x - self.x
		self.yy = y - self.y
	end
end

function 场景类_抽奖:开始移动(x,y)
	if self.鼠标 then
		self.x = x - self.xx
		self.y = y - self.yy
	end
end

return 场景类_抽奖